var xmlHttp;
var KeyId=getCookie('userId');

var local="http://47.104.10.151";
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
var stock_id1=stock_id1;
var stock_id2=stock_id2;
var stock_id3=stock_id3;
var stock_id4=stock_id4;
var stock_id5=stock_id5;
var stock_id6=stock_id6;
var stock_id7=stock_id7;
var stock_id8=stock_id8;
var stock_id9=stock_id9;
var stock_id10=stock_id10;


function creatxmlHTTP() {
    if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlHttp=new XMLHttpRequest();
    }else {
        // IE6, IE5 浏览器执行代码
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    return xmlHttp;
}

function warning() {
  alert("请先登陆");

}


function StorkOrder1() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid1").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id1;
    alert("请注意是否设置默认收货地址");
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var msg=json.msg;
            alert("购买一："+msg);
        }
    }

}

function StorkOrder2() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid2").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id2;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid1=json.msg;
            alert("购买二："+keyid1);
        }

    }

}

function StorkOrder3() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid3").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id3;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid2=json.msg;
            alert("购买三："+keyid2);
        }
    }

}

function StorkOrder4() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid4").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id4;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid3=json.msg;
            alert("购买四："+keyid3);
        }
    }

}

function StorkOrder5() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid5").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id5;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid4=json.msg;
            alert("购买五："+keyid4);
        }
    }

}

function StorkOrder6() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid6").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id6;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid5=json.msg;
            alert("购买六："+keyid5);
        }
    }

}

function StorkOrder7() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid7").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id7;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid6=json.msg;
            alert("购买七："+keyid6);
        }
    }

}

function StorkOrder8() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid8").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id8;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid7=json.msg;
            alert("购买七："+keyid7);
        }
    }

}

function StorkOrder9() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid9").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id9;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid3=json.msg;
            alert("购买九："+keyid3);
        }
    }

}

function StorkOrder10() {
    var url=local+":8080/stockorder/buyStock";
    xmlHttp=creatxmlHTTP();
    var txt="";//用于存储拼接字符串；
    //获取数据
    var stock_num=document.getElementById("bid10").value;
    //拼接字符
    txt="user_id="+KeyId+"&stock_num="+stock_num+"&stock_id="+stock_id10;

    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            var keyid3=json.msg;
            alert("购买十："+keyid3);
        }
    }

}